import configs
import time
from collections import deque


def event_mess(obj_activation_mess):
    len_mess = configs.obj_push_mess.qsize()
    obj_activation_mess.message(f"У вас {len_mess} сообщение Желаете озвучить")
    second = configs.time_out_mess_start + configs.time_out_mess_len
    if (configs.time_out_mess_len == 0 or second <= time.time()) and len_mess > 0:
        if configs.event_message == "cheek_message":
            if obj_activation_mess():
                while not configs.obj_push_mess.empty():
                    if not configs.obj_push_mess.empty():
                        configs.time_out_mess_start = 0
                        configs.time_out_mess_len = 0
                        id_mess = configs.obj_push_mess.get
                        yield id_mess
                    else:
                        configs.time_out_mess_start = time.time()
                        configs.time_out_mess_len = 3600
                        return None
            else:
                configs.time_out_mess_start = time.time()
                configs.time_out_mess_len = 3600
                return None
        else:
            configs.time_out_mess_start = time.time()
            configs.time_out_mess_len = 3600
            return None

    elif configs.event_message == "cheek_message":
        while not configs.obj_push_mess.empty():
            if not configs.obj_push_mess.empty():
                mess = configs.obj_push_mess.get()
                yield mess
            else:
                return None
    else:
        return None
